home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MACD 5
/
MACD 5.bin
/
workbench
/
libs
/
unixlib.lha
/
unix
/
src
/
close.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-10-10
|
575b
|
28 lines
#include "amiga.h"
#include "files.h"
#include <fcntl.h>
int __close(int fd)
{
struct fileinfo *fi;
__chkabort();
if (fi = _find_fd(fd)) {
int err = 0;
if (fi->count == 1)
err = fi->close(fi->userinfo, fi->flags & O_NO_CLOSE);
/*
* On return err is 0 if no error occurred, and negative otherwise.
* But if fd was the descriptor of a socket we get a positive value
* and thus not free the slot: the callback function called by AmiTCP
* will do that for us.
*/
if (err <= 0)
_free_fd(fd);
else
err = 0;
return err;
}
return -1;
}